<template>
  <div class="ask-item bgc-fff">
    <div class="item-head">
      <img :src="face" alt />
      <div class="head-title">
        <div class="head-name">{{ nickname }}</div>
        <div class="head-time">{{ createTime }}</div>
      </div>
      <!-- 问答，精华 -->
      <div class="head-jinghua jinghua-icon" v-if="jinghua == 1"></div>
    </div>

    <div class="item-content">
      <div class="content-info mb12 richText" v-html="content"></div>
      <viewer v-if="photopathThumb.length > 0" :images="photopathThumb">
        <div class="content-img">
          <img
            :src="img_url + item"
            v-for="item in photopathThumb"
            :key="item"
          />
        </div>
      </viewer>
      <!-- <div class="content-img" v-else >
        <img :src="img_url+item" v-for="item in photopathThumb" :key="item">
      </div> -->
      <!-- 问答，课程 评论数 -->
      <div class="content-commentNum" v-if="commentNum || commentNum === 0">
        <span>• {{ courseTitle }} •</span>
        <span class="_commentNum">
          <i class="icon16 huifu-icon"></i>
          {{ commentNum }}
        </span>
      </div>
    </div>
  </div>
</template>

<script>
import { mapState } from 'vuex'
export default {
  props: {
    // two 头像独占一列
    viewType: {
      type: String,
      default: '',
    },
    // 头像
    face: {
      type: String,
      default: '',
    },
    // 昵称
    nickname: {
      type: String,
      default: '',
    },
    // 创建时间
    createTime: {
      type: String,
      default: '',
    },
    // 内容
    content: {
      type: String,
      default: '',
    },
    // 帖子id
    id: {
      type: Number,
      default: null,
    },
    // 用户 id
    uid: {
      type: Number,
      default: null,
    },

    // 问答 特有字段
    // 评论数
    commentNum: {
      type: Number,
      default: null,
    },
    // 精华
    jinghua: {
      type: Number,
      default: null,
    },
    // 课程
    courseTitle: {
      type: String,
      default: '',
    },
    // 上传图片 最多3张
    photopathThumb: {
      type: Array,
      default: () => [],
    },
    // 上传图片，大图 如果有数据 说明要放大
    photopath: {
      type: Array,
      default: () => [],
    },
  },
  data() {
    return {}
  },
  computed: {
    ...mapState(['img_url']),
  },
  methods: {},
  mounted() {},
}
</script>

<style scoped lang="scss">
.ask-item {
  .item-head {
    display: flex;
    position: relative;

    > img {
      width: 0.4rem;
      height: 0.4rem;
      border-radius: 50%;
      flex: none;
    }

    // name time
    .head-title {
      margin-left: 0.1rem;
      width: 100%;
      .head-name {
        font-size: 0.14rem;
        font-weight: 500;
        color: rgba(48, 49, 51, 1);
        line-height: 0.2rem;
      }
    }
    .head-time {
      font-size: 0.12rem;
      font-weight: 500;
      color: rgba(144, 147, 153, 1);
      line-height: 0.17rem;
    }
  }

  .head-jinghua {
    position: absolute;
    right: 0;
    top: 0;
  }
  .head-huifu {
    position: absolute;
    top: 0.1rem;
    right: 0;
    font-size: 0.11rem;
    color: rgba(144, 147, 153, 1);
    line-height: 0.21rem;
    display: flex;
    align-items: center;
    .huifu-icon {
      margin-right: 0.02rem;
    }
  }
  // 点赞数
  .head-zan {
    position: absolute;
    top: 0.1rem;
    right: 0.64rem;
    font-size: 0.11rem;
    color: rgba(144, 147, 153, 1);
    line-height: 0.21rem;
    display: flex;
    align-items: center;
    .zan-icon {
      background: url('../../assets/images/like-icon.png') no-repeat
        center/cover;
      vertical-align: middle;
      margin-right: 0.02rem;
    }
    &.active {
      color: #f56c6c;
      .zan-icon {
        background: url('../../assets/images/like-icon-2.png') no-repeat
          center/cover;
      }
    }
  }

  // 评论数
  .head-commentNum2 {
    font-size: 0.12rem;
    font-weight: 500;
    color: #909399;
    line-height: 0.17rem;
    position: absolute;
    top: 0.1rem;
    right: 0;
  }
}

.item-content {
  margin-top: 0.12rem;
  &.two {
    margin-left: 0.5rem;
  }
  // 内容
  .content-info {
    word-break: break-all;
    word-break: break-all;
    color: #606266;
    line-height: 0.22rem;
  }
  // 上传图片
  .content-img {
    display: flex;
    flex-wrap: wrap;

    > img {
      width: 1.08rem;
      height: 1.08rem;
      border-radius: 0.02rem;
      margin-bottom: 0.12rem;
      margin-right: 0.08rem;
      &:last-child {
        margin-right: 0.08rem;
      }
    }
  }
  // 评论数
  .content-commentNum {
    display: flex;
    align-items: center;
    justify-content: space-between;
    span {
      font-size: 0.12rem;
      font-weight: 500;
      color: #909399;
      line-height: 0.17rem;
    }
    ._commentNum {
      position: relative;
      .huifu-icon {
        position: absolute;
        top: 0;
        right: 0.15rem;
      }
    }
  }
  // 多级回复
  .content-reply {
    background-color: #f6f6f6;
    color: #606266;
    padding: 12px;
    overflow: hidden;
    position: relative;
    li {
      font-size: 14px;
      margin-bottom: 6px;
      word-break: break-all;
      &:last-child {
        margin-bottom: 0;
      }
    }
    .expand {
      font-size: 12px;
      width: 100%;
      height: 32px;
      display: block;
      position: absolute;
      background-color: #f6f6f6;
      bottom: 0;
      left: 12px;
    }
  }
}

.huifu-icon {
  background: url('../../assets/images/message.png') no-repeat center/contain;
}
.jinghua-icon {
  width: 0.32rem;
  height: 0.14rem;
  background: url('../../assets/images/jinghua.png') no-repeat center/contain;
}
.expand-icon {
  background: url('../../assets/images/arrow-top-icon.png') no-repeat
    center/cover;
  position: relative;
  top: 4px;
}
.bluecolor {
  color: #0486fe;
}
</style>
